package com.alipay.sporadic.configuration;

import com.alipay.demo.trade.service.AlipayTradeService;
import com.alipay.demo.trade.service.impl.AlipayTradeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: sporadic
 * @description:
 * @author: LHD   QQ:1727865856
 * @create: 2019-10-30 20:15
 **/
@Configuration
@EnableConfigurationProperties(AliPayProperties.class)
public class AliPayConfig {
    @Autowired
    private AliPayProperties aliPayProperties;

    /**
     * 支付宝配置
     * @return
     */
    @Bean
    public AlipayTradeService alipayTradeService() {
        return new AlipayTradeServiceImpl.ClientBuilder()
                .setAppid(aliPayProperties.getAppid())
                .setCharset(aliPayProperties.getCharset())
                .setGatewayUrl(aliPayProperties.getGatewayUrl())
                .setAlipayPublicKey(aliPayProperties.getAlipayPublicKey())
                .setPrivateKey(aliPayProperties.getAppPrivateKey())
                .setSignType(aliPayProperties.getSignType())
                .setFormat(aliPayProperties.getFormate()).build();
    }

}
